約 3,066,388 件
https://w.atwiki.jp/progtips/pages/37.html
DLLを使う側のソースコード foo.cpp コンパイル cl /EHsc /Ox /nologo foo.cpp ソースコード #include cstdio #include windows.h #include io.h #include string using namespace std; class Importer { protected HMODULE dll; public string Msg; bool _Open(const string& dllname) { dll = LoadLibrary(dllname.c_str()); if (dll==NULL) { Msg = Importer DLL import fault \ ; Msg += dllname; Msg += \ . ; return false; } return true; } ~Importer() { if (dll) { FreeLibrary(dll); dll = 0; } } }; class MyImporter public Importer { public typedef int (*TyIntFunc)(int); typedef const char* (*TyDesc)(); TyIntFunc IntFunc; TyDesc Desc; bool operator()(const string& filename) { if (!_Open(filename)) { return false; } void* farproc[]={ &IntFunc, &Desc, }; const char* names[]={ Func , Description , }; for (int i=0; i 2; ++i) { FARPROC& ref = *((FARPROC*)farproc[i]); ref = GetProcAddress(dll, names[i]); if (ref==0) { Msg = Importer Function import fault \ ; Msg += names[i]; Msg += \ on \ ; Msg += filename; Msg += \ . ; return false; } } Msg = LoadFunc OK ; return true; } }; int main() { _finddata_t f; intptr_t hf = _findfirst( plugins/*.plugin.dll , &f); if (hf==-1) { puts( .plugin.dll not found ); return 0; } do { MyImporter mi; if (mi(string( plugins/ )+f.name)==false) { printf( %s\n , mi.Msg.c_str()); } else { printf( %-20s %d\n , mi.Desc(), mi.IntFunc(12345)); } } while (_findnext(hf,&f)==0); _findclose(hf); return 0; } div100.ja.plugin.cpp コンパイル cl /LD /Ox /nologo %%f ソースコード #define DLLFUNC extern C __declspec(dllexport) DLLFUNC const char* Description(void) { return 100で割る ; } DLLFUNC int Func(int x) { return x % 100; } 解説 exportする側はextern C がベター。C++モードの関数名は ?Func@@YAHH@Z 、 ?Description@@YAPBDXZ のような名前になるので、アクセスが面倒になってしまう。 実装その2 #include map #include string using namespace std; #define DLLFUNC extern C __declspec(dllexport) #define T(a,b) rsc[L## #a] = L##b; class SR { map rsc; public SR() { T(Name, Bascinet The Adventure ) T(Lang, 日本語 (.ja) ) } const wchar_t* operator[](const wchar_t* s) const { map const_iterator i = rsc.find(s); if (i==rsc.end()) { return L ; } return i- second.c_str(); } }; DLLFUNC const SR& StringResource(void) { static const SR rsc; return rsc; } DLLFUNC const wstring& Desc(int x) { static const wstring s(L 日本語(.ja)リソース ); return s; } #include clocale #include cstdio #include windows.h #include map #include io.h #include string using namespace std; class SR { map rsc; public SR() { } const wchar_t* operator[](const wchar_t* s) const { map const_iterator i = rsc.find(s); if (i==rsc.end()) { return L ; } return i- second.c_str(); } }; class Importer { protected HMODULE dll; public string Msg; bool _Open(const string& dllname) { dll = LoadLibrary(dllname.c_str()); if (dll==NULL) { Msg = Importer DLL import fault \ ; Msg += dllname; Msg += \ . ; return false; } return true; } ~Importer() { if (dll) { FreeLibrary(dll); dll = 0; } } }; class MyImporter public Importer { public typedef const SR& (*TyStringResource)(); typedef const wstring& (*TyDesc)(); TyStringResource StringResource; TyDesc Desc; bool operator()(const string& filename) { if (!_Open(filename)) { return false; } void* farproc[]={ &StringResource, &Desc, }; const char* names[]={ StringResource , Desc , }; for (int i=0; i 2; ++i) { FARPROC& ref = *((FARPROC*)farproc[i]); ref = GetProcAddress(dll, names[i]); if (ref==0) { Msg = Importer Function import fault \ ; Msg += names[i]; Msg += \ on \ ; Msg += filename; Msg += \ . ; return false; } } Msg = LoadFunc OK ; return true; } }; int main() { setlocale(LC_ALL, Japanese ); _finddata_t f; intptr_t hf = _findfirst( plugins/*.plugin.dll , &f); if (hf==-1) { puts( .plugin.dll not found ); return 0; } do { MyImporter mi; if (mi(string( plugins/ )+f.name)==false) { printf( %s\n , mi.Msg.c_str()); } else { wprintf(L Language %s\n , mi.Desc()); const SR& sr = mi.StringResource(); wprintf(L Name %s\n , sr[L Name ]); } } while (_findnext(hf,&f)==0); _findclose(hf); return 0; }
https://w.atwiki.jp/jfactory/pages/48.html
DLLの動的リンク アンマネージDLLを動的にリンクする(と、コールバックの実装) アンマネージDLLを動的にリンクする(と、コールバックの実装) OldDll.cpp #include "windows.h" #ifdef EXPORT #define DLLEXPORT __declspec(dllimport) #else #define DLLEXPORT __declspec(dllexport) #endif #ifdef _MANAGED #pragma managed(push, off) #endif #ifdef __cplusplus extern "C" { #endif typedef int (__stdcall *CallBackFuncPtr)( int ); static CallBackFuncPtr CallBackFunc; DLLEXPORT void SetFunc(CallBackFuncPtr ptr) { CallBackFunc = ptr; } DLLEXPORT int CallFunc(int i) { return CallBackFunc(i); } DLLEXPORT int TestFunc( int i) { return i; } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } #ifdef __cplusplus } #endif #ifdef _MANAGED #pragma managed(pop) #endif Test.cs using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices ; // for DllImport namespace Test { class Program { public delegate int CallbackProc(int i); [DllImport(@"..\..\..\debug\OldDll.dll")] public static extern int TestFunc(int i); [DllImport(@"..\..\..\debug\OldDll.dll")] public static extern int CallFunc(int i); [DllImport(@"..\..\..\debug\OldDll.dll")] public static extern void SetFunc(CallbackProc proc); static void Main(string[] args) { SetFunc(delegate (int i) { return i*2; }); Console.WriteLine("TestFunc(2) = " + TestFunc(2)); Console.WriteLine("CallFunc(2) = " + CallFunc(2)); Console.ReadLine(); } } }
https://w.atwiki.jp/civilization/pages/290.html
MOD/作成情報/CvGameCoreDLL.dllの作り方 MOD/作成情報/CvGameCoreDLL.dllの作り方 [#p81ecb84] 概要 [#ya1ba6e4] 参考URL [#v76addc5] Visual C++ 2008 Express Edition のインストール [#e3c873d8] Visual C++ Toolkit 2003 のインストール [#qdb5b418] マルチスレッドライブラリのダウンロード [#k67f6eb7] Microsoft R Windows Server 2003 R2 Platform SDK のインストール [#y4c651ce] SDKとmakefileの入手 [#m19b521d] プロジェクトの作成 [#w94e6fb6] ビルド [#ea3b5844] 動作確認 [#v5811ab9] 概要 Visual C++ 2008 Express Editionを使ってCvGameCoreDLL.dllを作る方法を説明します。Civ4 BtS 3.13 日本語版を使用。 参考URL 第9回CivilizationIVMOD解説講座‐ニコニコ動画(ββ) この文書はほぼこの動画をテキスト化したものです。動画の作者の人ありがとう。 第10回CivilizationIVMOD解説講座‐ニコニコ動画(ββ) BtS 3.13 用SDKの入手法 Installing and using the SDK - Civilization Fanatics Forums Civfanaticsのスレッド Civilization Fanatics Forums - Downloads Database - Makefile/Instructions BTS 3.17 SDK / Debugging Visual C++ 2008でSDKを開発する方法の解説。このページを書いてから存在に気付いたぜ…… Visual C++ 2008 Express Edition のインストール http //www.microsoft.com/japan/msdn/vstudio/Express/ #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 上記URLからダウンロードしてセットアップを実行。 Visual C++ Toolkit 2003 のインストール http //kael.civfanatics.net/files/VCToolkitSetup.exe マルチスレッドライブラリのダウンロード http //kael.civfanatics.net/files/msvcrt.lib http //kael.civfanatics.net/files/msvcrtd.lib http //kael.civfanatics.net/files/msvcprt.lib C \Program Files\Microsoft Visual C++ Toolkit 2003\lib に上記の3ファイルを置く。 Microsoft R Windows Server 2003 R2 Platform SDK のインストール http //www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB SDKとmakefileの入手 CvGameCoreDLL.dllのソースコードとビルドに必要なライブラリがSDKとしてBtS英語版には同梱されています。しかし日本語版には含まれていないので、どこからか探してくる必要があります。今回はCiv4 BTS Unofficial Patchのリポジトリに入っている修正前のSDKを使います。 http //civ4btspatch.svn.sourceforge.net/viewvc/civ4btspatch/CvGameCoreDLL/trunk/?pathrev=2 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) ページ下部の「Download GNU tarball」からダウンロードして解凍。 パッチ付属のSDKを使う場合、makefileが含まれていないため、この辺から別途makefileを入手し、CvGameCoreDLL直下に放り込む。 TOOLKIT=D /Programme/Microsoft Visual C++ Toolkit 2003/ PSDK=D /Programme/Microsoft Platform SDK のパスは自分の環境に合わせて修正すること。 プロジェクトの作成 Visual C++ 2008 を起動してプロジェクトを新規作成。 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 左ツリー「プロジェクトの種類」の「全般」を選択、画面右テンプレートで「メイクファイル プロジェクト」を選択。画面下のプロジェクト名と保存場所は適宜。「ソリューションのディレクトリを作成」はとりあえずオフに。 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) ウィザードで設定。 デバッグ構成の設定 ビルドコマンドライン nmake Debug 消去コマンド nmake clean_Debug #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) リリース構成の設定 デバック構成と同じ off ビルドコマンドライン nmake Final_Release 消去コマンド nmake clean_Final_Release #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 入力後「完了」で設定終了。 ダウンロードしたSDKのファイルをすべてプロジェクトのフォルダにコピー #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) ビルド ビルドの対象をReleaseにして #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 開始! #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 文字化けでエラー。CvGameTextMgr.cpp 2092行をとりあえずコメントアウトして凌ぐ。 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) 再びビルドして無事成功。[プロジェクトフォルダ]\Final_Release\CvGameCoreDLL.dll が目的のdllです。MODS\[MOD名]\Assets に置けばOK。 動作確認 CvUnit canMove() で常に true を返すようにしてみる。 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) できた CvGameCoreDLL.dll を My Documents\My Games\Beyond the Sword(J)\MODS\DllTest\Assets にコピーして civilization を起動、MOD DllTest をロード。 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (50%) いくらでも移動できるようになりました。作成したdllが働いていることが分かります。
https://w.atwiki.jp/gdiplus2/pages/12.html
重要 gdi++シリーズの開発はすべて終了しました。 今後このwikiの情報は更新されません。 現在はInkStoneの開発に移行していますのでそちらをご覧ください。 関連サイト The InkStone Project gdi++.dll(本家) ◆0x0D/0x20I氏(本家版+アイコンの作者。) gdi++.dll - windows(wiki) gdi++専用アップローダ gdi++うpろだEX(テスト版やiniうp、SS晒しとか) 業メモとか考えた事とか(via blog I/F) FreeType ProjectPortions of this software are copyright (c) 2005-2006The FreeType Project (www.freetype.org). All rights reserved. higambana氏 gdi++.dll@wiki に関するhtmlページまとめ(過去ログの一部が読めます) 2ch関係スレッド 【美しく】gdi++.dll スレッド【鮮やかに】 【美しく】gdi++.dll スレッド 2pt【鮮やかに】 gdi++.dll 3px gdi++.dll 4px gdi++.dll quality=5 gdi++.dll 6px gdi++.dll 7px gdi++.dll 8px gdi++.dll 8px(実質9px) gdi++.dll 9px(実質10px) gdi++.dll 11px gdi++.dll 11px(実質12px) gdi++.dll 13px gdi++.dll 14px gdi++.dll 15px gdi++.dll 16px gdi++.dll 17px 【叩き】gdi++.dll 18px【歓迎】 gdi++.dll 19px gdi++.dll 20px 【開発】gdi++.dll 21px【終了】(クソスレ) 【開発】gdi++.dll 21px【終了】(クソスレ) gdi++.dll 21px gdi++.dll 21px(実質22px)(クソスレ) gdi++.dll 23px gdi++の設定を晒すスレ gdi++.dll 質問スレ 1px 過去ログ7zip(1px-11px) html dat 紹介記事 窓の杜 - 【NEWS】指定したアプリ上であらゆるフォントの描画をなめらかにする「gdi++.dll」 どんなツールでもフォントをキレイにして実行する「gdi++.dll」 にゅーあきばどっとこむ スラッシュドット ジャパン | Windowsで綺麗なフォントレンダリングを実現する「gdi++.dll」 平林 純@「hirax.net」の科学と技術と男と女/Tech総研:「綺麗なフォントレンダリング」と「想定ユーザ」
https://w.atwiki.jp/ebi_xyz/pages/39.html
環境:VS2005 プロジェクト作成の流れ 「新しいプロジェクト」→「Visual C++」→「MFC」→「MFC DLL」を選択。「MFC DLLウィザード」が表示される。 「MFC DLLウィザード」→「DLL」の種類で「MFC拡張DLL」を選択。 CLASS定義CLASS名の前に「AFX_EXT_CLASS」を付ける 例 sampleクラスを定義する場合は以下 class AFX_EXT_CLASS sample { public sample(); ~sample(); public doSample(); private int x; int y; int z; } 外部アプリから参照される関数はdefファイルに定義 例 doSample()を定義。複数ある場合は@1から順に定義していく。 LIBRARY "sample" EXPORTS doSample()@1 2010-12-19
https://w.atwiki.jp/rock_on/
AtsSt.dllについて AtsSt.dllは、ATS-STをRock_Onが分かる範囲で模擬したクラスです。 実際の挙動とは異なる部分があるかと思いますが、ご容赦下さい。 StructureDefine.h 保安装置 CAtsFailSafe CAtsReceiver CAtsSt Ceb マスコン周辺 CMasconKey CEndSelectSwitch CMasterControler CReverser モニター装置 CMonitor CMotorWorkInd 汎用入出力デバイス CInputDevice COutputDevice NFB CDoorInterlockRelay CElectricBrakeNFB
https://w.atwiki.jp/gdiplus2/pages/46.html
gdi++.dll(Helium版) -スパゲッティコードからの脱却、高速化、そして新たなる高みへ- gdi++.dll(Helium版)概要作者 最新版 名前について 表示例 注意 基本的な使い方 FAQ、未解決の問題 その他(内容が古いかも) 概要 以下は付属マニュアル(gdi++.htm)からのコピペです。 コアエンジン (Helium と呼ぶ事にする) をフルスクラッチした gdi++ です。 具体的には…… SourceMonitor で Max Complexity が 30 以下になりました。 FreeType 内蔵キャッシュの使用を廃止し、独自のキャッシュシステムを使用することでメモリ消費量を削減しました。 MS Pゴシックなどの太字やイタリック体をエミュレートしているフォントで FontStream を多重に確保しないようにしました。 文字の描画に必要な API のみをフックし、その他は GDI の結果をそのまま使うようにしました。 マルチスレッドからの非同期アクセスに対する安定性が大幅に向上しました。 「一応0789(0577)ベースですが、もはやソースレベルでは別物」だそうです。 作者 gdi++9px(実質10px)740氏(コテ、トリップなし) 最新版 配布サイトはこちら。 名前について 表記 Helium版、Helium、ヘリウム、He版とか。決してヒーリウムではない。 名前変更の理由 ソースが前のバージョンとはもはや別物になってしまったから。 名前の由来 憶測で書いてますが・・・ 斧にアップしてたときファイル名の先頭にHe_がついてたから(Heはヘリウムの元素記号) 軽いから(ヘリウムは水素に次いで軽い) 安定してるから(ヘリウムはもっとも安定した分子) 表示例 gdi++専用アップローダへGO! 注意 実験版ですので必ず付属マニュアル(gdi++.htm)を読んでから使うように。 SSE2対応CPU(Pentium 4、Pentium M、Athlon64 以降の CPU)で動作します。 Windows XP SP3 以外での動作は保証しません。64 ビット版OSでの動作も保証しません freetype.dllは必ず Helium版と一緒に配布されているもの(dll.zipに同梱)を使用して下さい。 重大な欠陥が見つかった場合は予告無しに削除されるかもしれません。再配布・転載などはしないで下さい。 ネトラン厨お断り 基本的な使い方 Helium版の使い方はgdi++(FreeType)と同じですが、iniファイルのオプションが若干異なります。これについては付属マニュアル(gdi++.htm)が非常に丁寧なので、そちらを見て下さい。 ここではGdiTray(gdi++.dll を全プロセスに対して適用させるソフト)の使い方について述べます。 注 基本的なPCの操作、解凍の方法、iniファイルの書き方は理解しているものとします。 gdi++ Helium版、動作に必要なDLL及びGdiTrayをgdi++専用アップローダからDLし、全て同じフォルダに展開する。 付属マニュアル(gdi++.htm及びgditray.htm)を熟読する。 ファイル群を展開したフォルダにgdi++.iniを作成し、マニュアル(gditray.htm)に記載されたGdiTrayのiniファイルの内容を書く。 MultiINISelector=1の場合はiniフォルダを作成しそのフォルダ内に作成したiniファイルに、MultiINISelector=0の場合はgdi++.iniの続きにマニュアルに記載されたgdi++本体のiniファイルの内容を書く。 gditray.exeを起動。スタートアップにショートカットを作ればWindows起動時に自動で起動できます。 FAQ、未解決の問題 うちの CPU、SSE2 に対応してないんですけど・・・→ 頻繁に呼ばれる部分を随時 SIMD 化しているので、もう対応できません。ごめんなさい。 古いPCだからこそ軽いバージョン使いたいのがわからないのか!→ SSE2に特化することで軽くしてるんだから、諦めて0787でも使って下さい。 ソース無いんだが。→ ライセンスでグレーなところがあるかもしれないようで現在調査中のためソースは同梱されていません。 もっとちゃんとした使い方のマニュアルみたいなのはないの? 画像入りで分かりやすいやつ。→ もし良ければ書いて下さい。嫌なら親切な人が書いてくれるのを待って下さい。書く気はあるけど一人で全部書けないなら中途半端でもwikiに書くと誰か書き足してくれるかも。 全てのプロセスに適用させたい。→ 下のFAQにある方法を使うか、上のGdiTrayを使って下さい。 ○○○が落ちる。→ freetype.dllのバージョンは正しいですか? HDDに前のが残ってることもありうるので検索してみて下さい。もし正しければ開発スレに報告して下さい。OS、gdi++のバージョン、落ちるアプリケーション、CPU、メモリを明記すること。またフォント変えたら問題ない場合とかはフォントも。 その他(内容が古いかも) Tips FAQ
https://w.atwiki.jp/chugoku/pages/152.html
Windowsの場合、DLL 共有ファイルは以下のフォルダにあれば使える。 1.開発したアプリケーションの実行可能ファイル (.exe) があるディレクトリ(フォルダ) 2.カレントディレクトリ(カレントフォルダ) .exeのプログラムでフォルダを移動しない限り大抵1.と同じ 実行ファイルであるリンクファイルのExplorerのプロパティの作業フォルダのこと。コマンドでカレントフォルダの変更はcd。 3.Windowsのシステムディレクトリ(システムフォルダ) ? \windows\system32 4.Windows ディレクトリ(フォルダ) 5.環境変数のPATHに設定されているディレクトリ 名前 コメント 「今日の訪問数 - 」 「昨日の訪問数 - 」 「今までの訪問数 - 」
https://w.atwiki.jp/wnt0/pages/18.html
static リンクで、new しないで使うようにすると、 DLL に変更を加えたときに、アプリもビルドしなおさないといけない。 dynamic リンクのクラスDLLの作り方 http //www2s.biglobe.ne.jp/~ragnarok/program/win32/class_of_cpp_in_dll.htm http //hp.vector.co.jp/authors/VA041250/doc/plugin/#CHAP5_8 http //hp.vector.co.jp/authors/VA019517/howtodll.html MSDN http //msdn.microsoft.com/ja-jp/library/1ez7dh12(v=VS.80).aspx http //msdn.microsoft.com/ja-jp/library/cc429019.aspx (VS2005) STLクラスからの派生クラスを__declspec(dllexport)する場合の警告について http //msdn.microsoft.com/ja-jp/library/esew7y1w(v=vs.80).aspx extern "C" について http //www.geocities.jp/ky_webid/cpp/language/038.html DLL 側 ExportClass.h class ExportClass { public virtual void Func(void) = 0; virtual void Destroy(void) = 0; }; extern "C" __declspec(dllexport) ExportClass* CreateExportClassInstance(void); ExportClassImp.h #include "ExportClass.h" class ExportClassImp public ExportClass { public // 面倒なのでインライン ExportClassImp() { } void Func(void) { // 処理 } void Destroy(void) { delete this; } }; ExportClass.cpp #include "ExportClass.h" #include "ExportClassImp.h" BOOL APIENTRY DllMain() { // 省略 } __declspec(dllexport) ExportClass* CreateExportClassInstance(void) { return new ExportClassImp; } アプリ側 ExportClass.h class ExportClass { public virtual void Func(void) = 0; virtual void Destroy(void) = 0; }; extern "C" __declspec(dllimport) ExportClass* CreateExportClassInstance(void); ImportApp.cpp #include "ExportClass.h" typedef ExportClass* (*tagCreateExportClassInstance)(void); void ImportFunction(void) { HMODULE hDLL = LoadLibrary(_T("ExportClass.dll")); if (hDLL == NULL) { // error } tagCreateExportClassInstance create_func = (tagCreateExportClassInstance) GetProcAddress(hDLL, "CreateExportClassInstance"); if (create_func == NULL) { // error } // ExportClass インスタンスの生成 ExportClass *export_class = create_func(); // クラスメソッドの使用 export_class- Func(); export_class- Destroy(); FreeLibrary(hDLL); return 0; }
https://w.atwiki.jp/chugoku/pages/150.html
exeファイルの中にすべての関数の処理をバイナリで持たなくてもいい方法がある。WindowsではDLLファイルがC \WINDOWSやC \Windows\system32のフォルダに沢山あります。exeファイルは実行時にDLLファイルを自分のプロセス内のメモリに呼び込み(ほぼfopen関数状態)使う関数のアドレスを探し(PATH環境変数のフォルダにあるDLLファイルを自分で探す。exeファイルが置いてあるフォルダも探す)、実行できる状態になる。これは、コンパイル時のコマンドラインで渡すlibファイルなどのファイルの内容でDLLファイルを使うかどうかが決まる。関数の中身がコンパイルしたexeファイルに無いためexeファイルは小さくなる。 exeファイルとDLLファイルはどちらも実行可能なファイルだ。しかし、エクスプローラやcmd.exe(コマンドプロンプト)は拡張子を見て単独で実行可能かどうか判断するので拡張子がDLLの場合は単独では実行できない。 mylib.cpp----------------------------------------------------- __declspec(dllexport) int add(int a) { return (a+1); } mylib.h------------------------------------------------------- __declspec(dllimport) int add(int); main.cpp------------------------------------------------------ #include stdio.h #include"mylib.h" int main(void){ int i; i=1; i=add(5); printf("%d\n",i); return 0; } DLLファイルを作る。 C \usr\opencv\C_C++の練習\dll cl /LD mylib.cpp Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. mylib.cpp Microsoft (R) Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. /out mylib.dll /dll /implib mylib.lib mylib.obj ライブラリ mylib.lib とオブジェクト mylib.exp を作成中 libファイルも作られています。ファイルができていることを確認します。 C \usr\opencv\C_C++の練習\dll dir mylib.dll mylib.lib ドライブ C のボリューム ラベルがありません。 ボリューム シリアル番号は 8808-D6F4 です C \usr\opencv\C_C++の練習\dll のディレクトリ 2010/02/14 10 04 40,960 mylib.dll C \usr\opencv\C_C++の練習\dll のディレクトリ 2010/02/14 10 04 1,690 mylib.lib 2 個のファイル 42,650 バイト 0 個のディレクトリ 8,197,521,408 バイトの空き領域 dllファイルを使ったmain.cppをコンパイルして実行ファイルを作る。 C \usr\opencv\C_C++の練習\dll cl main.cpp mylib.lib Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. main.cpp Microsoft (R) Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. /out main.exe main.obj mylib.lib 実行します。 C \usr\opencv\C_C++の練習\dll main 6 C \usr\opencv\C_C++の練習\dll 本当に実行時にdllファイルを呼び込んでいるのか? dllファイルを変更してmain.exeを実行してみます。 returnの計算をa+1からa+100に変更します。 mylib.cpp------------------------------------------ __declspec(dllexport) int add(int a) { return (a+100); } C \usr\opencv\C_C++の練習\dll cl /LD mylib.cpp Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. mylib.cpp Microsoft (R) Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. /out mylib.dll /dll /implib mylib.lib mylib.obj ライブラリ mylib.lib とオブジェクト mylib.exp を作成中 C \usr\opencv\C_C++の練習\dll main 105 注意!。main.exeはコンパイルしてません。そのままです。 「今日の訪問数 - 」 「昨日の訪問数 - 」 「今までの訪問数 - 」 名前 コメント